/*
 * TwoApprKillNeighbor->cpp
 *
 *  Created on: 14 nov-> 2011
 *  Authors: bnoleau, cybourdi, rlecrois
 */

#include "TwoApprKillNeighbor.h"

TwoApprKillNeighbor::TwoApprKillNeighbor() {
}

TwoApprKillNeighbor::~TwoApprKillNeighbor() {
}

list<int> TwoApprKillNeighbor::vertexCover(Graph* g) {

	list<int> cover;

	for (int i = 0 ; i < g->numberOfNode(); i++) {
		if (g->nodeAt(i)->outDeg() > 0) {
			Node* currentNode = g->nodeAt(i); 
			Node* neighborNode = g->nodeAt(i)->getEdgeList()->front();
			cover.push_back(currentNode->getID());
            		cover.push_back(neighborNode->getID());
			g->eraseEdgesOfNode(currentNode);
			g->eraseEdgesOfNode(neighborNode);
		}
	}
	return cover;
}
